/**
 * Created by ZQZQQD on 2017/3/2.
 */
$(function(){
    /*--------------------------一周资讯-------------------------------------*/
    // 获取5条固定推荐资讯
    function queryFiveNewHnader(data) {
        if (data.success) {
            var html = '';
                var content = data.data;
                for (var c in content) {
                var cont=content[c];
                html += '<li class="dispaly-flex">'+
                    '<div class="flex-1">'+
                    '<div class="recommend-ready-item-title">'+cont.title+'</div>'+
                    '<div class="recommend-ready-bottom">'+
                    '<div class="recommend-ready-time">'+cont.time+'</div>'+
                    '<div class="recommend-ready-page-view">'+
                    '浏览：<span>'+cont.visitation+'</span>'+
                    '</div>'+
                    '</div>'+
                    '</div>'+
                    '<div class="recommend-ready-item-img">'+
                    '<img src="'+cont.imgs+'" alt="">'+
                    '</div>' +
                    '<input hidden id="' + cont.id + '" class="recommend-ready-id" type="text">' +
                    '</li>';
            }
            $('#recommendReadyList').html(html);
        } else {
            console.log("获取失败");
        }
    }
    /*----------------------加载获取固定5条数据----------------------*/
    function queryFiveNew() {
        var data = {};
        util.ajax('selectbychoiceness', data, queryFiveNewHnader);
        }
    /*-----------------------点击添加浏览量返回值----------------------*/
        function addNUmHander(data){
            if(data.success){
                console.log("添加成功");
            }
        }
    /*-----------------------点击添加浏览量----------------------*/
    function addNUm(id){
        var data={
            id:id
        };
        util.ajax('addviews', data,addNUmHander );
    }

    $("#recommendReadyList").on('click','.dispaly-flex',function(){

        var ids= $(this).find('input[ type="text"]').attr('id');
        window.localStorage.titleIsTrue=ids;
        window.location.href = "text_model.html";
        addNUm(ids);
    });
    queryFiveNew();
});